package com.distortiongames.level27.scenes
{
	import com.distortiongames.level27.components.render.TileRenderer;
	import com.distortiongames.level27.gameobjects.Player;
	import com.distortiongames.level27.gameobjects.Tile;
	import com.distortiongames.level27.generation.Map;
	import com.distortiongames.level27.generation.Point;
	import com.distortiongames.level27.math.Vector2D;
	import flash.display.Sprite;
	
	/**
	 * ...
	 * @author Jefferson Wagner
	 */
	public class GameScene extends MapScene
	{
		private var player:Player;
		
		public override function initialize():void
		{
			super.initialize();
			map = generator.lastMap;
			for (var y:int = 0; y < map.height; y++)
			{
				for (var x:int = 0; x < map.width; x++)
				{
					if (map.getTile(new Point(x, y)) != Map.EMPTY)
					{
						var tile:Tile = new Tile();
						tile.owningGroup = this;
						tile.initialize();
						tile.map.map = map;
						tile.position.point = new Point(x, y);
						tile.value.value = map.getTile(new Point(x, y));
					}
				}
			}
			timeManager.addTickedObject(this);
			
			player = new Player();
			player.owningGroup = this;
			player.initialize();
			player.position.vector = new Vector2D(generator.start.x * TileRenderer.WIDTH, generator.start.y * TileRenderer.HEIGHT);
		}
		
		public override function onTick():void
		{
		}
		
		public override function destroy():void
		{
			super.destroy();
		}
	
	}

}